#pragma once
#ifndef VISUALISATION_H
#define VISUALISATION_H

class CSprite;
class CAnimation;
#include <vector>
#include <HAPI_lib.h>
#include <tinyxml.h>

using namespace std;
enum ePolice
{
	ePolice1
};
class CVisualisation
{
private:
	//vector that store the sprite and animation
	static CVisualisation* instance;
	vector<CSprite*> vectorSprite;
	vector<CAnimation*> vectorAnimation;
	vector<int> vectorIndexFont;

	int screenWidth;
	int screenHeight;
	BYTE* screen;
	int beginTimeBlending;
	int endTimeBlending;
	
	TiXmlElement* element;

protected:
	CVisualisation(void);
	~CVisualisation(void);
public:
	static CVisualisation& getInstance(void);
	void CVisualisation::Close(void);

	/*function that create the graphic elements*/
	bool CVisualisation::createSprite(int* index, TiXmlElement* element);
	bool CVisualisation::createAnimation(int indexSprite, int* indexAnimation, int firstFrame, 
										 int lastFrame, int time);
	bool CVisualisation::createFont(TiXmlElement* element);

	/*function that display graphic element on the screen*/
	bool CVisualisation::displaySprite(int positionX, int positionY, int index, bool transparency);
	bool CVisualisation::displayFrame(int indexSprite, int positionX, int positionY, int indexFrame, 
									  bool transparency);
	bool CVisualisation::displayFrameBlending(int positionX, int positionY, int indexSprite, int indexFrame, 
											  int duration);
	bool CVisualisation::displaySpriteBlending(int positionX, int positionY, int index, int duration);
	bool CVisualisation::displayAnimation(int animation, int positionX, int positionY, int* currentFrame, 
										  int* timeLastFrame, bool transparency);
	void CVisualisation::displayHealth(int positionX, int positionY,int totalHealth, int currentHealth, int widthBar, int heightBar);
	void CVisualisation::displayNumberOfLife(int positionX,int positionY, int numberOfLife, int indexSprite, int indexFrame);
	bool CVisualisation::displayCharacter(char character, int police, int positionX, int positionY, bool transparency);
	bool CVisualisation::displayDigit(int digit, int police, int positionX, int positionY, bool transparency);
	bool CVisualisation::displayText(string text, int police, int positionX, int positionY, bool transparency);
	bool CVisualisation::displayNumber(int number, int police, int positionX, int positionY, bool transparency);
	bool CVisualisation::clearToColor(const HAPI_TColour *color);
	bool CVisualisation::setPixelToColor(const HAPI_TColour *color, int positionX, int positionY);
	//gettor for Visualisation's members//
	int CVisualisation::getScreenWidth(void)const;
	int CVisualisation::getScreenHeight(void)const;
	BYTE* CVisualisation::getScreen(void)const;

	//gettor for Sprite's members//
	int CVisualisation::getFrameWidth(int index)const;
	int CVisualisation::getFrameHeight(int index)const;
	int CVisualisation::getAnimationWidth(int index)const;
	int CVisualisation::getAnimationHeight(int index)const;

	//settor//
	void CVisualisation::setScreenWidth(int screenWidth);
	void CVisualisation::setScreenHeight(int screenHeight);
	void CVisualisation::setScreen(BYTE* const screen);

	
};
#define VIS CVisualisation::getInstance()

#endif